const path = require('path')

const filePath = './temp.txt'

// 文件扩展名
const fileExtension = path.extname(filePath)
console.log(fileExtension) // .txt